import pandas as pd
from sklearn.datasets import load_iris
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
from sklearn.manifold import TSNE

iris = load_iris()

data = pd.DataFrame(iris.data)

data_zs = (data - data.mean())/data.std()

k = 3

iteration = 3

model = KMeans(n_clusters=k, n_jobs=4, max_iter=iteration)

model.fit(data_zs)

pd.Series(model.labels_).value_counts()

pd.DataFrame(model.cluster_centers_)

tsne  =TSNE(learning_rate=100)

tsne.fit_transform(data_zs)

data = pd.DataFrame(tsne.embedding_, index=data_zs.index)

d = data[model.labels_==0]
plt.plot(d[0], d[1], 'r.')

d = data[model.labels_==1]
plt.plot(d[0], d[1], 'go')

d = data[model.labels_==2]
plt.plot(d[0], d[1], 'b*')

plt.show()

# import pandas as pd
# from sklearn.datasets import load_iris
# from sklearn.cluster import KMeans
# import matplotlib.pyplot as plt
# from sklearn.manifold import TSNE